#! /bin/sh -vx
# $Id$
# Copyright 2017 Karl Berry <tex-live@tug.org>
# Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_tftopl=$BinDir/tftopl$ExeExt

test -d tests || mkdir -p tests

# pre-generated test results in the repository are stored in LF
# but the output might be written in CRLF on some platform.
# if 'diff --strip-trailing-cr' is available, exploit it.
# (useful for tests on win32 binaries run on MSYS shell)
DIFF="diff"
$DIFF --strip-trailing-cr $0 $0 \
  && DIFF="diff --strip-trailing-cr" || echo

$_tftopl -char=foo -help || exit 1

$_tftopl -version || exit 2

TEXMFCNF=$srcdir/../kpathsea
export TEXMFCNF

$_tftopl -verbose $srcdir/tests/badtfm && exit 3

$_tftopl -verbose $srcdir/tests/cmr10 tests/xcmr10a || exit 4

diff $srcdir/tests/cmr10.pl tests/xcmr10a.pl || exit 5

$_tftopl -verbose $srcdir/tests/cmr10 >tests/xcmr10b.pl || exit 6

$DIFF $srcdir/tests/cmr10.pl tests/xcmr10b.pl || exit 7

